home *** CD-ROM | disk | FTP | other *** search
/ Quick PC 61 / Quick PC 61.iso / I386 / SASETUP.MSI / F77650_group_new.asp < prev    next >
Encoding:
Text File  |  2003-02-21  |  26.0 KB  |  806 lines

  1. <%@ Language=VBScript   %>
  2. <%    Option Explicit     %>
  3. <%
  4.     '-------------------------------------------------------------------------
  5.     ' group_new.asp: Serves in creating a new group
  6.     '
  7.     ' Copyright (c) Microsoft Corporation.  All rights reserved. 
  8.     '
  9.     ' Date             Description
  10.     ' 16-Jan-2001    Creation Date
  11.     '-------------------------------------------------------------------------
  12. %>
  13.     <!-- #include virtual="/admin/inc_framework.asp" -->
  14.     <!-- #include virtual="/admin/inc_accountsgroups.asp" -->
  15.     <!-- #include file="inc_usersngroups.asp" -->
  16. <%
  17.     '-------------------------------------------------------------------------
  18.     ' Global Constants and Variables
  19.     '-------------------------------------------------------------------------
  20.     Dim G_objService        'To get WMI connection
  21.     Dim G_CREDENTIAL_ERROR    'Error constant
  22.     
  23.     Dim rc                    'Return value for CreatePage
  24.     Dim page                'Variable that receives the output page object when
  25.                             'creating a page 
  26.     Dim idTabGeneral        'Variable for General tab 
  27.     Dim idTabMembers        'Variable for Members tab
  28.     
  29.     Const GC_ERR_ACCESS_DENIED = &H80070005
  30.     
  31.     '-------------------------------------------------------------------------
  32.     'Global Form Variables
  33.     '-------------------------------------------------------------------------
  34.     Dim F_strGroupName              'Group name
  35.     Dim F_strGrpDescription            'Group description
  36.     Dim F_strGroupMembers            'Members of the group
  37.     Dim F_strCurrentGroupMembers    'Current members of the group
  38.     Dim F_strCredentialID            'Credential ID
  39.     Dim F_strCredentialPSW            'Credential Password
  40.  
  41.     Const N_ACCOUNTALREADYEXIST_ERRNO            = &H800708B0
  42.     Const N_NONUNIQUEGROUPNAME_ERRNO            = &H80070563
  43.     Const N_GROUPNOTPRESENT_ERRNO                = &H8007056B
  44.     
  45.     '-------------------------------------------------------------------------
  46.     'Start of localization content
  47.     '-------------------------------------------------------------------------
  48.     Dim L_GROUP_NAME_TEXT
  49.     Dim L_DESCRIPTION_TEXT
  50.     Dim L_MEMBERS_TEXT
  51.     Dim L_ADD_TEXT
  52.     Dim L_REMOVE_TEXT
  53.     Dim L_PAGETITLE_GROUPNEW_TEXT
  54.     Dim L_ADDUSERORGROUP_TEXT
  55.     Dim L_NOINPUTDATA_TEXT
  56.     Dim L_TABPROPSHEET_TEXT
  57.     Dim L_DOMAINUSERHELP_TEXT
  58.     Dim L_MEMBERSPROMPT_TEXT
  59.     Dim L_HOWTO_ADDDOMAINUSER_TEXT
  60.     Dim L_HOWTO_ENTERCREDENTIALS_TEXT
  61.     Dim L_USERNAME_PROMPT_TEXT
  62.     Dim L_PASSWORD_PROMPT_TEXT
  63.     Dim L_DUPLICATEMEMBER_ERRORMESSAGE
  64.     Dim L_SELECTMEMBER_ERRORMESSAGE
  65.     Dim L_NONUNIQUEGROUPNAME_ERRORMESSAGE
  66.     Dim L_ACCOUNTALREADYEXIST_ERRORMESSAGE
  67.     Dim L_GROUPNOTCREATED_ERRORMESSAGE
  68.     Dim L_GROUPNOTPRESENT_ERRORMESSAGE
  69.     Dim L_GROUPPROPERTIESNOTSET_ERRORMESSAGE
  70.     Dim L_MEMBERADDITIONFAILED_ERRORMESSAGE
  71.     Dim L_GROUPNAMENOTVALID_ERRORMESSAGE
  72.     Dim L_INVALIDCHARACTER_ERRORMESSAGE
  73.     Dim L_LOCALIZATIONOBJECTFAILED_ERRORMESSAGE
  74.     Dim L_COMPUTERNAME_ERRORMESSAGE
  75.     Dim L_DOMUSERINVALIDCHARACTER_ERRORMESSAGE
  76.     Dim L_USERNOTFOUND_ERRORMESSAGE
  77.     Dim L_INVALIDDOMAINUSER_ERRORMESSAGE
  78.     Dim L_LONGGRPDESCRIPTION_ERRORMESSAGE
  79.     Dim L_CREDENTIALS_ERRORMESSAGE
  80.     Dim L_GENERAL_TEXT
  81.     
  82.     L_GENERAL_TEXT = GetLocString("usermsg.dll", "&H4031000A", "")
  83.     L_HOWTO_ADDDOMAINUSER_TEXT = GetLocString("usermsg.dll", "403100C8", "")
  84.     L_HOWTO_ENTERCREDENTIALS_TEXT = GetLocString("usermsg.dll", "403100C9", "")
  85.     L_USERNAME_PROMPT_TEXT = GetLocString("usermsg.dll", "403100CA", "")
  86.     L_PASSWORD_PROMPT_TEXT = GetLocString("usermsg.dll", "403100CB", "")
  87.     L_GROUP_NAME_TEXT = GetLocString("usermsg.dll", "&H40310001", "")
  88.     L_DESCRIPTION_TEXT = GetLocString("usermsg.dll", "&H40310030", "")
  89.     L_MEMBERS_TEXT = GetLocString("usermsg.dll", "&H40310002", "")
  90.     L_ADD_TEXT = GetLocString("usermsg.dll", "&H40310003", "")
  91.     L_REMOVE_TEXT = GetLocString("usermsg.dll", "&H40310004", "")
  92.     L_PAGETITLE_GROUPNEW_TEXT = GetLocString("usermsg.dll", "&H40310005", "")
  93.     L_ADDUSERORGROUP_TEXT = GetLocString("usermsg.dll", "&H40310006", "")
  94.     L_NOINPUTDATA_TEXT = GetLocString("usermsg.dll", "&H40310007", "")
  95.     L_TABPROPSHEET_TEXT = GetLocString("usermsg.dll", "&H40310008", "")
  96.     L_DOMAINUSERHELP_TEXT = GetLocString("usermsg.dll", "&H4031000B", "")
  97.     L_MEMBERSPROMPT_TEXT = GetLocString("usermsg.dll", "&H40310042", "")
  98.  
  99.     'Error Messages
  100.     L_DUPLICATEMEMBER_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC031000C", "")
  101.     L_SELECTMEMBER_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC031000D", "")
  102.     L_NONUNIQUEGROUPNAME_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC031000E", "")
  103.     L_ACCOUNTALREADYEXIST_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC031000F", "")
  104.     L_GROUPNOTCREATED_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310010", "")
  105.     L_GROUPNOTPRESENT_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310011", "")
  106.     L_GROUPPROPERTIESNOTSET_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310012", "")
  107.     L_MEMBERADDITIONFAILED_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310013", "")
  108.     L_GROUPNAMENOTVALID_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310014", "")
  109.     L_INVALIDCHARACTER_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310015", "")
  110.     L_LOCALIZATIONOBJECTFAILED_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310017", "")
  111.     L_COMPUTERNAME_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310018", "")
  112.     L_DOMUSERINVALIDCHARACTER_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310019", "")
  113.     L_USERNOTFOUND_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC031001B", "")
  114.     L_INVALIDDOMAINUSER_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC031001A", "")
  115.     L_LONGGRPDESCRIPTION_ERRORMESSAGE = GetLocString("usermsg.dll", "&HC0310038", "")
  116.         
  117.     '-------------------------------------------------------------------------
  118.     ' END of localization content
  119.     '-------------------------------------------------------------------------
  120.     
  121.     '
  122.     'Create a Tabbed Property Page
  123.     rc = SA_CreatePage( L_PAGETITLE_GROUPNEW_TEXT , "", PT_TABBED, page )
  124.     
  125.     '
  126.     'Add two tabs
  127.     rc = SA_AddTabPage( page, L_GENERAL_TEXT, idTabGeneral)
  128.     rc = SA_AddTabPage( page, L_MEMBERS_TEXT, idTabMembers)
  129.     
  130.     '
  131.     'Show the page
  132.     rc = SA_ShowPage( page )
  133.     
  134.     '---------------------------------------------------------------------
  135.     'Function:                OnInitPage()
  136.     'Description:            Called to signal first time processing for this page.
  137.     'Input Variables:        PageIn,EventArg
  138.     'Output Variables:        None
  139.     'Returns:                True/False
  140.     'Global Variables:        G_objService,F_strGroupMembers,L_WMI_CONNECTIONFAIL_ERRORMESSAGE
  141.     '---------------------------------------------------------------------
  142.     Public Function OnInitPage(ByRef PageIn, ByRef EventArg)
  143.         
  144.         OnInitPage = TRUE
  145.             
  146.         'Connecting to the server
  147.         Set G_objService=GetWMIConnection("Default")
  148.         
  149.         If Err.number <> 0 Then
  150.             ServeFailurePage L_WMI_CONNECTIONFAIL_ERRORMESSAGE,1
  151.         End if
  152.  
  153.         'Get the members of the domain & computer
  154.         F_strGroupMembers = getLocalUsersList(G_objService)
  155.         
  156.     End Function
  157.     
  158.     '---------------------------------------------------------------------
  159.     'Function:                OnPostBackPage()
  160.     'Description:            Called to signal that the page has been posted-back.
  161.     'Input Variables:        PageIn,EventArg
  162.     'Output Variables:        None
  163.     'Returns:                True/False
  164.     'Global Variables:        F_(*),G_objService,L_WMI_CONNECTIONFAIL_ERRORMESSAGE
  165.     '---------------------------------------------------------------------
  166.     Public Function OnPostBackPage(ByRef PageIn, ByRef EventArg)
  167.     
  168.         F_strGroupName = Request.form("txtGroupName")
  169.         F_strGrpDescription = Request.form("txaGrpDescription")
  170.         F_strCurrentGroupMembers = Request.form("hdnGrpMembers")
  171.         F_strCredentialID = Request.form("txtCredentialID")
  172.         F_strCredentialPSW = Request.form("txtCredentialPSW")
  173.         
  174.         'Connecting to the server
  175.         Set G_objService=GetWMIConnection("Default")
  176.         
  177.         If Err.number <> 0 Then
  178.             ServeFailurePage L_WMI_CONNECTIONFAIL_ERRORMESSAGE,1
  179.         End if
  180.         
  181.         F_strGroupMembers = getLocalUsersList(G_objService)
  182.         
  183.         OnPostBackPage = True
  184.         
  185.     End Function
  186.     
  187.     '---------------------------------------------------------------------
  188.     'Function:                OnServeTabbedPropertyPage()
  189.     'Description:            Called when the content needs to send
  190.     'Input Variables:        PageIn,EventArg,iTab,bIsVisible
  191.     'Output Variables:        None
  192.     'Returns:                True/False
  193.     'Global Variables:        iTab
  194.     '---------------------------------------------------------------------
  195.     Public Function OnServeTabbedPropertyPage(ByRef PageIn, _
  196.                                                     ByVal iTab, _
  197.                                                     ByVal bIsVisible, ByRef EventArg)
  198.         '
  199.         ' Emit Web Framework required functions
  200.         If ( iTab = 0 ) Then
  201.             Call ServeCommonJavaScript()
  202.         End If
  203.  
  204.         '
  205.         ' Emit content for the requested tab
  206.         Select Case iTab
  207.             Case idTabGeneral
  208.                 Call ServeTabGeneral(PageIn, bIsVisible)
  209.             Case idTabMembers
  210.                 Call ServeTabMembers(PageIn, bIsVisible)
  211.             Case Else
  212.                 SA_TraceOut "TEMPLAGE_TABBED", _
  213.                     "OnServeTabbedPropertyPage unrecognized tab id: " + CStr(iTab)
  214.         End Select
  215.             
  216.         OnServeTabbedPropertyPage = TRUE
  217.         
  218.     End Function
  219.  
  220.     '---------------------------------------------------------------------
  221.     'Function:                OnSubmitPage()
  222.     'Description:            Called when the page has been submitted for processing.
  223.     'Input Variables:        PageIn,EventArg
  224.     'Output Variables:        None
  225.     'Returns:                True/False
  226.     'Global Variables:        None
  227.     '---------------------------------------------------------------------
  228.     Public Function OnSubmitPage(ByRef PageIn, ByRef EventArg)
  229.         
  230.         'Create new group on submitting the page
  231.         OnSubmitPage = CreateNewGroup()
  232.         
  233.     End Function
  234.     
  235.     '---------------------------------------------------------------------
  236.     'Function:                OnClosePage()
  237.     'Description:            Called when the page is about closed.
  238.     'Input Variables:        PageIn,EventArg
  239.     'Output Variables:        None
  240.     'Returns:                True/False
  241.     'Global Variables:        None
  242.     '---------------------------------------------------------------------
  243.     Public Function OnClosePage(ByRef PageIn, ByRef EventArg)
  244.     
  245.         OnClosePage = TRUE
  246.         
  247.     End Function
  248.  
  249.     '-------------------------------------------------------------------------
  250.     'Function:                ServeTabGeneral()
  251.     'Description:            For displaying outputs HTML for tab 1 to the user
  252.     'Input Variables:        PageIn,bIsVisible    
  253.     'Output Variables:        None
  254.     'Returns:                gc_ERR_SUCCESS
  255.     'Global Variables:        F_strGroupName,F_strGrpDescription,F_strCurrentGroupMembers,L_(*)
  256.     '-------------------------------------------------------------------------
  257.     Function ServeTabGeneral(ByRef PageIn, ByVal bIsVisible)
  258.     
  259.         If (bIsVisible) Then
  260. %>
  261.             <TABLE WIDTH=518 VALIGN=middle ALIGN=left BORDER=0 CELLSPACING=0
  262.                    CELLPADDING=2 class="TasksBody">
  263.             <TR>
  264.                 <TD width=25% NOWRAP>
  265.                     <%=L_GROUP_NAME_TEXT %>
  266.                 </TD>
  267.                 <TD align="left" colspan="2">
  268.                     <INPUT class ="FormField" TYPE="text" NAME ="txtGroupName" STYLE="WIDTH:180px" VALUE="<%=Server.HTMLEncode(F_strGroupName)%>" MAXLENGTH="20" onKeyUp="CheckInput(txtGroupName)" onChange="CheckInput(txtGroupName)">
  269.                 </TD>
  270.             </TR>
  271.             <TR>
  272.                 <TD width=25% NOWRAP>
  273.                     <%=L_DESCRIPTION_TEXT %>
  274.                 </TD>
  275.                 <TD>
  276.                     <input NAME="txaGrpDescription" TYPE="text" SIZE="40" onFocus="document.onkeypress=null" onBlur="document.onkeypress=HandleKeyPress" VALUE="<%=server.htmlencode(F_strGrpDescription)%>" maxlength=300>
  277.                 </TD>
  278.             </TABLE>
  279. <%
  280.         Else
  281. %>        
  282.             <INPUT TYPE="HIDDEN" NAME="hdnGrpMembers" VALUE="<%=Server.HTMLEncode(F_strCurrentGroupMembers)%>">
  283.             <INPUT TYPE="HIDDEN"  NAME ="txtGroupName"  VALUE="<%=Server.HTMLEncode(F_strGroupName)%>" >
  284.             <INPUT TYPE="HIDDEN" NAME="txaGrpDescription" value="<%=Server.HTMLEncode(F_strGrpDescription)%>" >
  285. <%
  286.          End If
  287.          
  288.         ServeTabGeneral = gc_ERR_SUCCESS
  289.         
  290.     End Function
  291.  
  292.     '-------------------------------------------------------------------------
  293.     'Function:                ServeTabMembers()
  294.     'Description:            For displaying outputs HTML for tab 2 to the user
  295.     'Input Variables:        PageIn,bIsVisible
  296.     'Output Variables:        None
  297.     'Returns:                gc_ERR_SUCCESS
  298.     'Global Variables:        L_(*)
  299.     '-------------------------------------------------------------------------
  300.     Function ServeTabMembers(ByRef PageIn, ByVal bIsVisible)
  301.         
  302.         Call ServeCommonJavaScript()
  303.         
  304.         If (bIsVisible) Then
  305. %>
  306.             <TABLE WIDTH=300 VALIGN=middle BORDER=0 CELLSPACING=0 CELLPADDING=2 class="TasksBody">
  307.                             
  308.                 <TR>
  309.                     <TD colspan=6>
  310.                     <% CheckForSecureSite %>
  311.                     </TD>
  312.                 </TR>
  313.             
  314.                 <TR>
  315.                     <TD>
  316.                       
  317.                     </TD>
  318.                 </TR>
  319.             
  320.             
  321.                 <TR>
  322.                     <TD nowrap width=190><%=L_MEMBERSPROMPT_TEXT %></TD>
  323.                     <TD> </TD>
  324.                     <TD> <%=L_ADDUSERORGROUP_TEXT %> </TD>
  325.                 </TR>
  326.                  <TR>
  327.                       <TD nowrap valign=top width=190>
  328.                           <SELECT class ="FormField" SIZE="9" NAME="lstCurrrentMembers" onChange="ClearErr()">
  329.                          <%
  330.                              ServetoListBox(F_strCurrentGroupMembers)
  331.                          %>
  332.                          </SELECT>
  333.                      </TD>
  334.                     <TD valign="center" align="center" width="110" HEIGHT="30px">
  335.                          <INPUT TYPE="button" class="TaskButtons" VALUE="<%=Server.HTMLEncode(L_ADD_TEXT)%>" NAME="btnAddMember" onClick="addMember();SetData()">
  336.                          <BR>
  337.                          <INPUT TYPE="button" class="TaskButtons" VALUE="<%=Server.HTMLEncode(L_REMOVE_TEXT)%>" NAME="btnRemoveMember" onClick="removeMember();SetData()">
  338.                      </TD>
  339.                     <TD valign="top">
  340.                     
  341.                          <SELECT class ="FormField" SIZE="7" NAME="lstDomainMembers" onChange="ClearErr();document.frmTask.btnAddMember.disabled = false;" multiple>
  342.                          <%
  343.                              ServetoListBox(F_strGroupMembers)
  344.                          %>
  345.                          </SELECT>
  346.                      </TD>
  347.                 </TR>
  348.             </TABLE>
  349.     
  350.             <p><%=L_DOMAINUSERHELP_TEXT%>
  351.             <p><%=L_HOWTO_ADDDOMAINUSER_TEXT%>
  352.     
  353.             <TABLE VALIGN=middle BORDER=0 CELLSPACING=0 CELLPADDING=2 class="TasksBody">
  354.                 <TR nowrap>
  355.                     <TD nowrap width=180><INPUT class ="FormField" TYPE = "text" STYLE="WIDTH:180px" Name ="txtDomainUser" onKeyUP ="disableAddButton(this,document.frmTask.btnAddDomainMember)"></TD>
  356.                     <TD><INPUT TYPE="button" class="TaskButtons" VALUE="<%=Server.HTMLEncode(L_ADD_TEXT)%>" NAME="btnAddDomainMember" onClick="addDomainMember(document.frmTask.txtDomainUser);SetData()"></TD>
  357.                 </TR>        
  358.             </TABLE>
  359.     
  360.             <br>    
  361.             <p><%=L_HOWTO_ENTERCREDENTIALS_TEXT%>
  362.             
  363.             <TABLE VALIGN=middle BORDER=0 CELLSPACING=0 CELLPADDING=2 class="TasksBody">
  364.                 <TR>
  365.                     <TD><%=Server.HTMLEncode(L_USERNAME_PROMPT_TEXT)%></TD>
  366.                     <TD><INPUT class ="FormField" TYPE = "text" STYLE="WIDTH:180px" Name ="txtCredentialID" value="<%=F_strCredentialID%>" ></TD>
  367.                 </TR>
  368.                 <TR>
  369.                     <TD><%=Server.HTMLEncode(L_PASSWORD_PROMPT_TEXT)%></TD>
  370.                     <TD><INPUT class ="FormField" TYPE = "password" STYLE="WIDTH:180px" Name ="txtCredentialPSW" value="<%=F_strCredentialPSW%>"></TD>
  371.                 </TR>
  372.  
  373.             </TABLE>
  374. <%
  375.         Else
  376. %>
  377.             <INPUT TYPE="HIDDEN" NAME="hdnGrpMembers" VALUE="<%=Server.HTMLEncode(F_strCurrentGroupMembers)%>">
  378.             <INPUT TYPE="HIDDEN"  NAME ="txtCredentialID"  VALUE="<%=Server.HTMLEncode(F_strCredentialID)%>" >
  379.             <INPUT TYPE="HIDDEN" NAME="txtCredentialPSW" VALUE="<%=Server.HTMLEncode(F_strCredentialPSW)%>" >
  380. <%
  381.          End If
  382.          
  383.         ServeTabMembers = gc_ERR_SUCCESS
  384.         
  385.     End Function
  386.  
  387.     '-------------------------------------------------------------------------
  388.     'Function:                ServeCommonJavaScript
  389.     'Description:            Serves in initialiging the values,setting the form
  390.     '                        data and validating the form values
  391.     'Input Variables:        None
  392.     'Output Variables:        None
  393.     'Returns:                True/False
  394.     'Global Variables:        In-F_(*) -All form variables
  395.     '                        In-L_(*)-Localization variables
  396.     '-------------------------------------------------------------------------
  397.     Function ServeCommonJavaScript()
  398. %>
  399.         <script language="JavaScript" src="<%=m_VirtualRoot%>inc_global.js">
  400.         </script>
  401.         <script language="JavaScript">
  402.     
  403.             // Set the initial form values
  404.             var objForm = eval("document.frmTask")
  405.             var intSelTab = objForm.TabSelected.value
  406.             
  407.             function Init()
  408.             {
  409.                 var strReturnurl=location.href
  410.                 var tempCnt=strReturnurl.indexOf("&ReturnURL=");
  411.                 var straction=strReturnurl.substring(0,tempCnt)
  412.                 
  413.                 objForm.action = straction
  414.                 objForm.Method.value = ""
  415.  
  416.                 // Set OK Button status
  417.                 if ( objForm.txtGroupName )
  418.                 {
  419.                     if ( document.frmTask.txtGroupName.value.length < 1 )
  420.                     {
  421.                         DisableOK();
  422.                     }
  423.                     else
  424.                     {
  425.                         EnableOK();
  426.                     }
  427.                 }
  428.                 
  429.                 //Checks for whether there are any members in the domain
  430.                 //if its general tab
  431.                 if(intSelTab == '0')
  432.                 {
  433.                     objForm.txtGroupName.focus()
  434.                 }
  435.                 else
  436.                 {
  437.                     if(objForm.lstDomainMembers.length == 0 )
  438.                     {
  439.                         objForm.lstDomainMembers.disabled = true;
  440.                         objForm.btnAddMember.disabled = true;
  441.                         objForm.btnRemoveMember.disabled = true;
  442.                     }
  443.                     else
  444.                     {
  445.                         objForm.lstDomainMembers.options[0].selected = true;
  446.                     }
  447.  
  448.                     if (objForm.lstCurrrentMembers.length ==0)
  449.                     {
  450.                         objForm.btnRemoveMember.disabled=true
  451.                     }
  452.                     else
  453.                     {
  454.                         objForm.lstCurrrentMembers.options[0].selected =true;
  455.                         objForm.btnRemoveMember.disabled =false
  456.                     }
  457.                     disableAddButton(document.frmTask.txtDomainUser,document.frmTask.btnAddDomainMember)
  458.                     <% If ( G_CREDENTIAL_ERROR ) Then %>
  459.                     objForm.txtCredentialID.focus();
  460.                     <% End If %>
  461.                 }
  462.             }
  463.  
  464.             // Validate the page form values
  465.             function ValidatePage()
  466.             {
  467.                 var strGroupName
  468.                 var strErrmsg
  469.  
  470.                 if(intSelTab == '0')
  471.                 {
  472.                     strGroupName = document.frmTask.txtGroupName.value
  473.                     strErrmsg = ""
  474.  
  475.                     if (Trim(strGroupName) == "" || isAlldots(strGroupName))
  476.                     {
  477.                         strErrmsg = "<%=Server.HTMLEncode(L_GROUPNAMENOTVALID_ERRORMESSAGE)%>" + strGroupName + "  <%=Server.HTMLEncode(L_INVALIDCHARACTER_ERRORMESSAGE)%>"
  478.                         DisplayErr(strErrmsg);
  479.  
  480.                         //if its general tab
  481.                         if(intSelTab == '0')
  482.                         {
  483.                             document.frmTask.txtGroupName.focus()
  484.                             document.frmTask.onkeypress = ClearErr
  485.                         }
  486.                         return false;
  487.                     }
  488.  
  489.                     // Checks for invalid key entry
  490.                     if(!isvalidchar("/[\/\*\?\"<>\|+=,;:\[\\]\\\\\]/",strGroupName))
  491.                     {
  492.                         strErrmsg = "<%=Server.HTMLEncode(L_GROUPNAMENOTVALID_ERRORMESSAGE)%>" + strGroupName + "  <%=Server.HTMLEncode(L_INVALIDCHARACTER_ERRORMESSAGE)%>"
  493.                         SA_DisplayErr(strErrmsg);
  494.  
  495.                         //if its general tab
  496.                         if(intSelTab == '0')
  497.                         {
  498.                             document.frmTask.txtGroupName.focus()
  499.                             document.frmTask.onkeypress = ClearErr
  500.                         }
  501.                         return false;
  502.                     }
  503.  
  504.                     //Checking for length of the description
  505.                     if(document.frmTask.txaGrpDescription.value.length > 256)
  506.                     {
  507.                         SA_DisplayErr("<%=Server.HTMLEncode(L_LONGGRPDESCRIPTION_ERRORMESSAGE) %>");
  508.  
  509.                         //if its general tab
  510.                         if(intSelTab == '0')
  511.                         {
  512.                             document.frmTask.txaGrpDescription.focus()
  513.                             document.frmTask.onkeypress = ClearErr
  514.                         }
  515.                         return false;
  516.                     }
  517.                 }
  518.                 return true;
  519.             }
  520.  
  521.             // function to set the hidden field with the selected DNS server
  522.             // list values
  523.             function SetData()
  524.             {
  525.                 var nIdx
  526.                 var strTemp
  527.  
  528.                 strTemp =""
  529.  
  530.                 //if its  general tab
  531.                 if(intSelTab == '0')
  532.                     return true
  533.                 
  534.                 for(nIdx=0;nIdx < objForm.lstCurrrentMembers.length ; nIdx++)
  535.                 {
  536.                     strTemp = strTemp+ String.fromCharCode(1)+ objForm.lstCurrrentMembers.options[nIdx].value
  537.                      + String.fromCharCode(2)+ objForm.lstCurrrentMembers.options[nIdx].text
  538.  
  539.                 }
  540.                 objForm.hdnGrpMembers.value =strTemp
  541.             }
  542.  
  543.             // Adds the group member to the listbox
  544.             function addMember()
  545.             {
  546.                 var strText
  547.                 var objListBox
  548.                 var strDomainName
  549.                 var nIdx
  550.                 var strValue
  551.  
  552.                 objListBox = eval("document.frmTask.lstDomainMembers")
  553.  
  554.                 if(objListBox.selectedIndex == -1)
  555.                 {
  556.                     SA_DisplayErr("<%=Server.HTMLEncode(L_SELECTMEMBER_ERRORMESSAGE)%>");
  557.                     document.frmTask.onclick = ClearErr
  558.                     document.frmTask.onkeypress = ClearErr
  559.                     return false
  560.                 }
  561.                 
  562.                 // code added for adding multiple entries into a list box
  563.                 for(nIdx =0 ; nIdx <objListBox.length ; nIdx++)
  564.                 {
  565.                     if(objListBox.options[nIdx].selected)
  566.                     {
  567.                         strText  = objListBox.options[nIdx].text
  568.                         strValue  = objListBox.options[nIdx].value
  569.                         addToListBox(objForm.lstCurrrentMembers,document.frmTask.btnRemoveMember,strText,strValue)
  570.                         objForm.lstCurrrentMembers.disabled= false
  571.                     }
  572.                 }
  573.                 objListBox.selectedIndex = -1
  574.                 document.frmTask.btnAddMember.disabled = true
  575.             }
  576.  
  577.             //Deletes the group member in the listbox
  578.             function removeMember()
  579.             {
  580.                 removeListBoxItems(objForm.lstCurrrentMembers,objForm.btnRemoveMember)
  581.  
  582.             }
  583.  
  584.             //Function to enable or disable OK button
  585.             function CheckInput(objText)
  586.             {
  587.                 if(objText.value !="")
  588.                 {
  589.                     EnableOK();
  590.                 }
  591.                 else 
  592.                 {
  593.                     DisableOK();
  594.                 }
  595.             }
  596.  
  597.             function isAlldots(strInput)
  598.             {
  599.                 var nIdx
  600.  
  601.                 for(nIdx=0;nIdx < strInput.length ; nIdx++)
  602.                 {
  603.                      if (strInput.charAt(nIdx) != ".")
  604.                         return false
  605.                 }
  606.                 return true
  607.             }
  608.  
  609.             //Function to add a domain user
  610.             function addDomainMember(objDomainUser)
  611.             {
  612.                 var strText
  613.                 var strValue
  614.                 var objListBox
  615.  
  616.                 objListBox = eval("document.frmTask.lstDomainMembers")
  617.                 
  618.                 // Checks For Invalid charecters in username
  619.                 if(!isvalidchar("/[\/\*\?\"<>\|+=,;:\[\\]\]/",objDomainUser.value))
  620.                 {
  621.                     SA_DisplayErr("<% =Server.HTMLEncode(L_DOMUSERINVALIDCHARACTER_ERRORMESSAGE) %>");
  622.                     document.frmTask.onkeypress = ClearErr
  623.                     return false;
  624.                 }
  625.  
  626.                 strText  =objForm.txtDomainUser.value;
  627.                 strValue =objForm.txtDomainUser.value;
  628.  
  629.                 //Checking for the domain\user format
  630.                 if( strText.match( /[^(\\| )]{1,}\\[^(\\| )]{1,}/ ) )
  631.                 {
  632.                     if(!addToListBox(objForm.lstCurrrentMembers,objForm.btnAddDomainMember,strText,strValue))
  633.                     {
  634.                         SA_DisplayErr("<%=Server.HTMLEncode(L_DUPLICATEMEMBER_ERRORMESSAGE)%>");
  635.                         document.frmTask.onkeypress = ClearErr
  636.                         return false;
  637.                     }
  638.                     
  639.                     objForm.txtDomainUser.value =""
  640.                     objForm.btnAddDomainMember.disabled = true;
  641.                     
  642.                     if(objListBox.length != 0 )
  643.                     {
  644.                         objForm.btnRemoveMember.disabled = false;
  645.                     }
  646.                 }
  647.                 else
  648.                 {
  649.                     SA_DisplayErr("<%=Server.HTMLEncode(L_INVALIDDOMAINUSER_ERRORMESSAGE)%>");
  650.                     document.frmTask.onkeypress = ClearErr
  651.                 }
  652.             }
  653.         </script>
  654. <%
  655.     End Function
  656.  
  657.     '---------------------------------------------------------------------
  658.     'Function name:        CreateNewGroup
  659.     'Desription:        Serves in Creating the NewGroup
  660.     'Input Variables:    None
  661.     'Output variables:    None
  662.     'Returns:            True / Flase  on success/Failure
  663.     'Global Variables:    F_strGroupName,F_strGrpdescription,F_strUsersList,
  664.     '                    F_strCurrentGroupMembers,F_strCredentialID, F_strCredentialPSW,
  665.     '                    G_CREDENTIAL_ERROR,G_objService,L_(*)
  666.     '---------------------------------------------------------------------
  667.     Function CreateNewGroup
  668.         Err.Clear
  669.         On Error Resume Next
  670.  
  671.         Dim objComputer
  672.         Dim objGroup
  673.         Dim arrUserNames
  674.         Dim nCnt
  675.         Dim nLoopCount
  676.         Dim strCompName
  677.         Dim strPath
  678.         Dim strAdsPath
  679.         Dim strDomain
  680.         Dim arrTemp
  681.         Dim strErrorCode
  682.         Dim aParam(1)
  683.         Dim strarg
  684.         
  685.         L_CREDENTIALS_ERRORMESSAGE = GetLocString( "usermsg.dll", "C03100CC", strarg)
  686.         
  687.         'Intializing variables to have the computer name & domain name
  688.         strCompName= GetComputerName()
  689.         strPath = "Domain="""& strCompName &""",Name="""&F_strGroupName&""""
  690.         strDomain = getConnectedDomain(G_objService)
  691.  
  692.         'Check whether the group already exists
  693.         if isValidInstance(G_objService,"win32_group",strPath) then
  694.             SetErrMsg L_NONUNIQUEGROUPNAME_ERRORMESSAGE
  695.             CreateNewGroup = false
  696.             Exit Function
  697.         end if
  698.  
  699.         'If the system is in a domain
  700.         if strDomain <> "" then
  701.             F_strCurrentGroupMembers = replace(F_strCurrentGroupMembers,chr(1)&strCompName ,chr(1)&strDomain & "\"&strCompName)
  702.         end if
  703.         
  704.         'Replace "\" with "/"
  705.         F_strCurrentGroupMembers = replace(F_strCurrentGroupMembers,"\","/")
  706.  
  707.         arrUserNames=split(F_strCurrentGroupMembers,chr(1))
  708.         nLoopCount=Ubound(arrUserNames)
  709.  
  710.         'Looping for each user in the selected List
  711.         For nCnt=1 To nLoopCount
  712.             arrTemp =split(arrUserNames(nCnt),chr(2))
  713.             If instr(arrTemp(1) ,"/") > 0 then
  714.                 'If Instr(strUserName,"/") then
  715.                     If isValidMember(arrTemp(1), F_strCredentialID, F_strCredentialPSW, strErrorCode) = false then
  716.                         If (strErrorCode = GC_ERR_ACCESS_DENIED ) Then
  717.                             aParam(0) = replace(arrTemp(1),"/","\")
  718.                             strarg = aParam
  719.                             SetErrMsg L_CREDENTIALS_ERRORMESSAGE
  720.                             G_CREDENTIAL_ERROR = TRUE
  721.                         Else
  722.                             Call SA_TraceOut(SA_GetScriptFileName(), "IsValidMember failed, error: " & Hex(Err.Number) & " " & Err.Description)
  723.                             SetErrMsg L_USERNOTFOUND_ERRORMESSAGE & replace(arrTemp(1),"/","\")
  724.                         End If
  725.  
  726.                         'Replace "\" with "/"
  727.                         F_strCurrentGroupMembers = replace(F_strCurrentGroupMembers,"/","\")
  728.  
  729.                         CreateNewGroup=FALSE
  730.                         Exit Function
  731.                     End if
  732.                 'End if    
  733.             End if
  734.         Next
  735.         ' End for loop
  736.         
  737.         'Get the ADSI computer object
  738.         Set objComputer = GetObject("WinNT://" & strCompName  & ",computer")
  739.  
  740.         'Create the group & set the description
  741.         Set objGroup=objComputer.Create("Group",F_strGroupName)
  742.         objGroup.Description=F_strGrpDescription
  743.  
  744.         'Set the changes
  745.         objGroup.setInfo()
  746.         
  747.         'Error handling
  748.         If Err.number <> 0 Then
  749.         
  750.             'Checking for uniqueness  of the GroupName
  751.             If Err.Number = N_NONUNIQUEGROUPNAME_ERRNO then
  752.                 SetErrMsg L_NONUNIQUEGROUPNAME_ERRORMESSAGE
  753.             'Checking for uniqueness  of the AccountName
  754.             Elseif Err.number = N_ACCOUNTALREADYEXIST_ERRNO then
  755.                 SetErrMsg L_ACCOUNTALREADYEXIST_ERRORMESSAGE
  756.             Else
  757.                 SetErrMsg L_GROUPNOTCREATED_ERRORMESSAGE
  758.             End If
  759.             
  760.             CreateNewGroup=FALSE
  761.             Exit Function
  762.         End If
  763.  
  764.         'Looping for each user in the selected List
  765.         For nCnt=1 To nLoopCount
  766.             arrTemp =split(arrUserNames(nCnt),chr(2))
  767.             
  768.             If ( Len(Trim(F_strCredentialID)) > 0 ) Then
  769.                 Call AddUserToGroup( F_strGroupName, arrTemp(0), F_strCredentialID, F_strCredentialPSW )
  770.                 If ( Err.Number <> 0 ) Then
  771.                     Exit For
  772.                 End If
  773.             Else
  774.                 strAdsPath="WinNT://" & arrTemp(0)
  775.                 objGroup.add(strAdsPath)            
  776.             End If
  777.  
  778.         Next
  779.  
  780.         'Set to Nothing
  781.         Set objComputer    =Nothing
  782.         set objGroup    =Nothing
  783.  
  784.         'Error handling
  785.         If Err.number <> 0 Then
  786.             
  787.             'checking for user existence
  788.             If Err.number = N_GROUPNOTPRESENT_ERRNO Then
  789.                 SetErrMsg L_GROUPNOTPRESENT_ERRORMESSAGE
  790.             Else
  791.                 SetErrMsg L_MEMBERADDITIONFAILED_ERRORMESSAGE
  792.             End If
  793.             
  794.             'Replace "\" with "/"
  795.             F_strCurrentGroupMembers = replace(F_strCurrentGroupMembers,"/","\")
  796.             CreateNewGroup=FALSE
  797.             Exit Function
  798.         End If
  799.  
  800.         CreateNewGroup=TRUE
  801.         
  802.     End Function
  803. %>
  804.  
  805.  
  806.